<? isset($format) || $format =  url_param(null, array('page' => '%d')); ?>
<? if (isset($page) && $page->total_pages > 1): ?>
<ul class="pagination <?=get_var('extraClass')?>">

    <li class="<?=on($page->current == 1, 'disabled')?>">
        <a href="<?=furl($format, 1)?>" title="<?=__('First')?>">
            <i class="fa fa-angle-double-left"></i>
        </a>
    </li>

    <li class="<?=on($page->current <= 1, 'disabled')?>">
        <a href="<?=furl($format, $page->before)?>" title="<?=__('Previous')?>">
            <i class="fa fa-angle-left"></i>
        </a>
    </li>

    <? if ($page->total_pages < 4): ?>

        <? for ($i = 1; $i <= 3; $i++): ?>
            <li class="<?=on($i == $page->current, 'active')?>"><a href="<?=furl($format, $i)?>"><?=$i?></a></li>
        <? endfor ?>

    <? elseif ($page->current < 3): ?>

        <? for ($i = 1; $i <= 3; $i++): ?>
            <li class="<?=on($i == $page->current, 'active')?>"><a href="<?=furl($format, $i)?>"><?=$i?></a></li>
        <? endfor ?>

    <? elseif ($page->current > $page->total_pages - 3): ?>

        <? for ($i = $page->total_pages - 2; $i <= $page->total_pages; $i++): ?>
            <li class="<?=on($i == $page->current, 'active')?>"><a href="<?=furl($format, $i)?>"><?=$i?></a></li>
        <? endfor ?>

    <? else: ?>

        <? for ($i = $page->current - 1; $i <= $page->current + 1; $i++): ?>
            <li class="<?=on($i == $page->current, 'active')?>"><a href="<?=furl($format, $i)?>"><?=$i?></a></li>
        <? endfor ?>

    <? endif ?>

    <li class="<?=on($page->current >= $page->total_pages, 'disabled')?>">
        <a href="<?=furl($format, $page->next)?>" title="<?=__('Next')?>">
            <i class="fa fa-angle-right"></i>
        </a>
    </li>

    <li class="<?=on($page->current >= $page->total_pages, 'disabled')?>">
        <a href="<?=furl($format, $page->total_pages)?>" title="<?=__('Last')?>">
            <i class="fa fa-angle-double-right"></i>
        </a>
    </li>
</ul>
<? endif ?>
